package com.singzi.leetcode.N1600;

public class T1576 {
    public static void main(String[] args) {
        String s = "ubv?w";
        Solution1576 solution1576 = new Solution1576();
        System.out.println(solution1576.modifyString(s));
    }
}
class Solution1576 {
    public String modifyString(String s) {

        char[] letters = s.toCharArray();
        if(letters.length==1){
            if(letters[0] == '?') return "a";
            else return s;
        }
        if(letters[0] == '?'){
            if(letters[1] != '?') letters[0] = (char)(97+((int)letters[1]-97)%25+1);
            else letters[0] = 'a';
        }
        for (int i = 1; i < s.length(); i++) {
            int c = 97+((int)letters[i-1]-97)%25+1;
            if(letters[i] == '?')
                letters[i] = (char)(c);
            if(i<s.length()-1 && letters[i]==letters[i+1]) letters[i] =  (char)(97+((int)letters[i+1]-97)%25+1);
        }
        s = new String(letters);
        return s;
    }
}